<?php
namespace Home\Controller;
use Think\Controller;
class DeviceController extends CommonController {
    public function data_list(){
        $limit = I("pageSize", 30, "intval");
        $page = I("pageCurrent", 1, "intval");
        $search_words = I('search_words');
        if($search_words!=null&&$search_words!=''){
            $condition['dev_id'] = array('eq',$search_words);
        }
        $this->assign('search_words',$search_words);
        if(I('dev_status')!=null&&I('dev_status')!=''){
            $condition['dev_status'] = array('eq',I('dev_status'));
        }
        if(I('dev_version')!=null&&I('dev_version')!=''){
            $condition['dev_version_id'] = array('eq',I('dev_version'));
        }
        $versionList = M("Version")->select();
        $this->assign("versionList",$versionList);

        $device_model = D("Device");
        $count = $device_model->get_count($condition);
        $dataList = $device_model->get_device_list($condition, $limit, $page);
        $this->assign("count",$count);
        $this->assign("dataList",$dataList);
    	$this->display();
    }
    public function operation(){
        $device_model = D("Device");
        $data['dev_create_time'] = time();
        $result = $device_model->add($data);
        if($result){
            exit(success('成功！'));
        }else{
            exit(error('失败！'));
        }
    }
}